<%@ page import="com.party.core.model.system.TargetType" %>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="../include/tag.jsp"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>新增记录</title>
    <%@include file="../include/commonFile.jsp"%>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">

</head>
<body>
<div class="index-outside">
    <section class="no-fix">
        <div class="section-main">
            <div class="add-form-content pr20">
                <form id="myForm" class="layui-form mt20" method="post" action="${ctx}/records/records/save.do">
                    <input type="hidden" name="id" />
                    <div class="layui-form-item">
                        <label class="layui-form-label">众筹者<span class="f-verify-red">*</span></label>
                        <div class="layui-input-block">
                            <input type="hidden" name="targetId" value="${upRecords.targetId}" />
                            <input type="text"   class="layui-input" value="${authorName}" readonly>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">图像</label>
                        <div class="cover-content">
                            <input type="hidden" name="pic" id="pic" lay-verify="pic" />
                            <span id="logo-img" class="cover-img" style="background-image:url(${ctx}/image/posterImg.png)"></span>
                            <a class="layui-btn layui-btn-danger" id="sel_pic_img">+添加图片</a>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">内容<span class="f-verify-red">*</span></label>
                        <div class="layui-input-block">
                            <textarea name="content" id="content" placeholder="内容" lay-verify="content" class="layui-textarea" ></textarea>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </section>
</div>

<script>
    $(function() {
        layui.use([ 'form', 'laydate' ], function() {
            var form = layui.form, laydate = layui.laydate;


            //自定义验证规则
            form.verify({
                content : function (value) {
                    if (!value){
                        return '请填写跟进内容';
                    }
                }
            });

        });

        $('#sel_pic_img').click(function () {
            txz.openSelImg({
                min: 1,
                max: 1,
                type: '<%=TargetType.ZC_ACTIVITY.getCode()%>',
                cb: function (imgs) {
                    $('#logo-img').css('background-image', 'url(' + imgs[0].path + ')');
                    $('#pic').val(imgs[0].path);
                }
            })
        })
    })

    function doSubmit(){
        var content = $("[name=content]").val();
        if(content == ''){
            util.layerMsgError("请填写跟进内容")
            return '';
        }
        var action = $("#myForm").attr("action");
        $.post(action, $('#myForm').serialize(), function(res) {
            if (res.success) {
                util.layerMsgSuccess("提交成功", function () {
                });
            } else {
                util.layerMsgError("提交失败")
            }
        });
        return $("#content").val();
    }
</script>
</body>
</html>